package com.ruoyi.web.controller.base.pc;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.system.domain.request.EmpInfoReq;
import com.ruoyi.system.service.AddUserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@Slf4j
@RestController
@RequestMapping("/createUser")
public class AddUserController {

    @Autowired
    private AddUserService addUserService;
    @PostMapping("/createUser2AIE")
    @Transactional
    public AjaxResult createUser2Aie(@RequestParam("file") MultipartFile file
            , @RequestParam String userId
            , @RequestParam String userName
            , @RequestParam String card
            , @RequestParam String sex
            , @RequestParam String phone
            , @RequestParam String position
            , @RequestParam String empFromId
            , @RequestParam String workPlace
            , @RequestParam String jopId
    ) {

        EmpInfoReq req=new EmpInfoReq();
        req.setEmpId(userId);
        req.setEmpCard(card);
        req.setEmpImg(userId);
        req.setEmpName(userName);
        req.setEmpSex(sex);
        req.setEmpPhone(phone);
        req.setEmpPost(position);
        req.setEmpAttribute("01");
        req.setEmpFromId(empFromId);
        req.setWorkPlace(workPlace);
        req.setJobId(jopId);

        PersonHelper helper =new PersonHelper();
        helper.addUserHelper(req,file,addUserService);

        return AjaxResult.error("成功");
    }
}
